package com.sh.sh_ai_agent.demo.invoke;


import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class SpringAiAiInvoke implements CommandLineRunner {

    /**
     * 这里Resource通过名称注入，所以这里dashScopeChatModel要写对
     */
    @Resource
    private ChatModel dashScopeChatModel;

    @Override
    public void run(String... args) throws Exception {
        AssistantMessage res = dashScopeChatModel.call(new Prompt("你是谁")).getResult().getOutput();
        System.out.println(res.getText());
    }
}
